# libspngstream - simple png manipulation lib

CFLAGS:= -Wall -Werror -fpic -std=c99 -pedantic
CXX:= gcc
LIB:= libspngstream.so
PREFIX:= /usr/local

LDFLAGS:=
LDFLAGS+= -l m
LDFLAGS+= -l png

OBJ:= armath.o readpng.o writepng.o libspngstream.o
HEA:= $(OBJ:.o=.h) def.h

all: $(LIB)

%.o: src/%.c src/%.h src/def.h
	$(CXX) $(CFLAGS) -c $<

$(LIB): $(OBJ)
	$(CXX) -shared -o $(LIB) $(OBJ) $(LDFLAGS)
	rm *.o

install: all
	@mkdir -p ${DESTDIR}${PREFIX}/
	@echo installing header files to ${DESTDIR}${PREFIX}/include
	@cp -f src/*.h ${DESTDIR}${PREFIX}/include
	@echo installing shared library to ${DESTDIR}${PREFIX}/lib
	@cp -f ${LIB} ${DESTDIR}${PREFIX}/lib
	@chmod 755 ${DESTDIR}${PREFIX}/lib/${LIB}

uninstall:
	@echo removing header files from ${DESTDIR}${PREFIX}/include
	@rm -f $(addprefix ${DESTDIR}${PREFIX}/include/, $(HEA))
	@echo removing shared object from ${DESTDIR}${PREFIX}/lib
	@rm -f ${LIB} ${DESTDIR}${PREFIX}/lib/${LIB}

clean:
	rm -f $(LIB) *.o

.PHONY: all clean install uninstall
